"""
@Project:${2108a 人工智能}
@File:JWT_auth.py
@Author:周家昌
@Date:14:54
"""
from flask import request,g,jsonify
from common.utils.token_utils import token_auth

def jwt_authorization():
    '''鉴权验证'''
    token = request.headers.get('Authorization')
    if token and token.startswith('JWT '):
        token = token[4:]
        payload = token_auth(token)
        if type(payload) == dict:
            g.uid = payload.get('id')
        else:
            return jsonify(code=401,msg=payload)
